<template>
	<view class="body">
		<!-- <view><text class="titlee">土地面积</text>：{{info.mianji}}</view>
		<view><text class="titlee">单价</text>：{{info.price}}</view>
		<view><text class="titlee">共计费用</text>：{{info.money}}</view>
		<view><text class="titlee">定金</text>：{{info.ding_money}}</view>
		<view><text class="titlee">尾款</text>：{{info.wei_money}}</view>
		<view><text class="titlee">耕作要求</text>：{{info.yaoqiu}}</view>
		<view><text class="titlee" @click="call(info.phone)">联系方式</text>：{{info.phone}}
			<u-icon name="phone-fill" color="#2979ff" size="32"></u-icon>
		</view>
		<view @click="goAddress(info.address)"><text class="titlee">地址</text>：{{info.address}}
			<u-icon name="map-fill" color="#2979ff" size="32"></u-icon>
		</view>
		<button class="btn" @click="qiang(info.id)">马上申请</button> -->
		<view class="word_bd">
			<!-- 顶部盒子 -->
		  <view class="word_top">
				
			<!-- 顶部图片 -->
			<view class="top_img">
				<image src="https://jy.data.lingdongnet.com/uploads/20230713/FpY6kgzN2sLvOLP4pmoaoFYrqYeJ.jpg" mode="scaleToFill"></image>
			</view>
			<!-- 顶部内容 -->
			<view class="top_font">
				<view class="font_text">
					<text style="font-weight: 700;">{{info.title}}</text>
					<text class="text_green">{{info.price}}元/亩</text>
				</view>
				
				<!-- <view class="font_icon" style="margin-top: 10rpx;">
					<u-icon name="photo" color="green" size="60"></u-icon>
				</view> -->
			</view>
			<!-- 耕作要求 -->
			<view class="word_middle">
				<text style="font-size: 32rpx; font-weight: 900; margin-bottom: 10rpx;">耕作要求</text>
					<view class="bd_bd">
						<!-- <view>· 耕作时间：<text>2023年7月15日10:31:58</text></view> -->
						<!-- <view>· 共计天数：<text>21天</text></view> -->
						<view>· 共计亩数：<text>{{info.mianji}}</text></view>
						<view>· 单价：<text>{{info.price}}元/亩</text></view>
						<view>· 定金：<text>{{info.ding_money}}</text></view>
						<view>· 尾款：<text>{{info.wei_money}}</text></view>
						<view>· 共计费用：<text>{{info.money}}</text></view>
						<!-- <view>· 农机要求：<text>无</text></view> -->
						<view style="color: green;">· 必须要求：<text>{{info.yaoqiu}}</text></view>
					</view>
				<!-- <text style="font-size: 28rpx;">收割台高度离地S15CM，秸秆切碎长度≤10CM，收割作业损失率≤1.5%</text> -->
				<!-- <view style="color: green; margin: 20rpx 0; ">查看全部</view> -->
			</view>
			<!-- 需求来源 -->
			<view class="word_btm">
				<view style="margin-bottom: 20rpx; font-size: 30rpx; font-weight: 900;">需求来源</view>
				<view class="btm_font">
					<view class="font_left">
						<text style="font-size: 24rpx; color: #9d9d9d;">发布者</text>
						<text style="margin: 10rpx 0;">{{info.u_name}}</text>
					</view>
					<view class="font_right"  @click="call(info.phone)">
						<u-icon name="phone-fill"></u-icon>
						<text style="margin-left: 5rpx;">电话联系TA</text>
					</view>
				</view>
				<view class="btm_font">
					<view class="font_left">
						<text style="font-size: 24rpx; color: #9d9d9d;">位置</text>
						<text style="margin: 10rpx 0;">{{info.address}}</text>
					</view>
					<view class="font_right" @click="goAddress(info.address)">
						<u-icon name="map-fill"></u-icon>
						<text style="margin-left: 5rpx;">查看位置</text>
					</view>
				</view>
			</view>
			<!-- 按钮 -->
			<view class="word_btn" @click="qiang(info.id)">
				马上申请
			</view>
		  </view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				options:[],
				info:[]
			}
		},
		onLoad(options) {
			this.options = options;
			this.getInfo(options.work_id);
		},
		methods: {
			getInfo(id){
				var _this = this;
				_this.$http('apply.work_detail',{
					work_id:id
				}).then(res=>{
					if(res.code == 1){
						_this.info = res.data;
					}else if(res.code == 0){
						uni.showModal({
							title:'提示',
							content:res.msg,
							success(ret){
								if(ret.confirm){
									uni.redirectTo({
										url:'/pages/index/njs_apply'
									})
								}
								if(ret.cancel){
									uni.redirectTo({
										url:'/pages/index/dating'
									})
								}
							}
						})
					}
				})
			},
			//抢单
			qiang(id) {
				var _this = this;
				_this.$http('apply.njs_jiehuo', {
					work_id: id
				}).then(res => {
					if (res.code == 1) {
						uni.showModal({
							title: '提示',
							content: '申请待农户审核',
							success() {
								_this.page = 1;
								_this.list = [];
								_this.getList(1)
							}
						})
					}
				})
			},
			goAddress(address) {
				uni.request({
					url: 'https://apis.map.qq.com/ws/geocoder/v1/?address=' + address +
						'&key=ULIBZ-LTS3J-HMRFZ-KFRPH-W2E4S-BFFKQ',
					success(res) {
						console.log(res);
						uni.openLocation({
							latitude: res.data.result.location.lat,
							longitude: res.data.result.location.lng,
							success(ret) {

							}

						})
					}
				})
			},
			call(mobile) {
				uni.makePhoneCall({
					phoneNumber: mobile
				})
			}

		}
	}
</script>

<style>
	.body {
		width: 100%;
		height: auto;
		min-height: 1320rpx;
		background-color: #fff;
	}
	.top_img {
		height: 400rpx;
		width: 100%;
	}
	.top_img image {
		height: 100%;
		width: 100%;
	}
	.top_font {
		padding-bottom: 30rpx;
		margin: 30rpx;
		display: flex;
		justify-content: space-between;
		border-bottom: 2rpx solid red;
	}
	.font_text {
		display: flex;
		flex-direction: column;
	}
	.text_green {
		color: #66c09b;
		 font-size: 38rpx;
		  font-weight: 700;
	}
	.word_middle {
		margin: 0 30rpx;
		/* padding: 0 30rpx; */
		display: flex;
		flex-direction: column;
		border-bottom: 2rpx solid red;
	}
	.bd_bd {
	line-height: 60rpx;
	font-size: 24rpx;
	margin: 10rpx 0;
	}
	.word_btm {
		margin: 20rpx 30rpx;
	}
	.btm_font {
		display: flex;
		justify-content: space-between;
	}
	.font_left {
		display: flex;
		flex-direction: column;
		width: 75%;
	}
	.font_right {
		margin: 15rpx 0 0 0;
		color: green;
		font-size: 26rpx;
	}
	.word_btn {
		margin: 0 30rpx;
		height: 80rpx;
		width: 92%;
		color: #fff;
		background-color:  rgb(75, 187, 137);
		line-height: 80rpx;
		text-align: center;
		border-radius: 10rpx;
	}
</style>